import com.hbm.Event;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;

import java.util.Date;

/**
 * Created by CrazyShaQiuShi on 2017/4/11.
 */
public class GetSqlFactory {

    private static SessionFactory sessionFactory;

    public static void main(String[] args) {
        final StandardServiceRegistry registry = new StandardServiceRegistryBuilder().configure().build();
        sessionFactory = new MetadataSources(registry).buildMetadata().buildSessionFactory();
        System.out.println(sessionFactory);

        Session session = sessionFactory.openSession();
        session.beginTransaction();
        session.save(new Event("zhangsan", new Date()));
        session.save(new Event("lisi", new Date()));
        session.getTransaction().commit();
        session.close();
    }
}
